package com.gitee.wsl.compose.base

import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalContext
import androidx.compose.runtime.ProvidedValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.platform.SoftwareKeyboardController
import androidx.lifecycle.compose.LocalLifecycleOwner

object Local


/*inline val Local.configuration @Composable
    get() = LocalConfiguration.current*/

inline val Local.lifecycleOwner @Composable
    get() = LocalLifecycleOwner.current

inline val Local.density @Composable
    get() = LocalDensity.current

inline val Local.contentColor @Composable
    get() = LocalContentColor.current

@Composable
fun Local.contentColor(color: Color, content: @Composable () -> Unit) = valueOf(LocalContentColor provides color,content)

@Suppress("ComposableNaming")
@Composable
fun Local.valueOf(value: ProvidedValue<*>,  content: @Composable () -> Unit) = androidx.compose.runtime.CompositionLocalProvider(value, content)

@Suppress("ComposableNaming")
@Composable
 fun Local.valueOf(vararg value: ProvidedValue<*>, content: @Composable () -> Unit) = androidx.compose.runtime.CompositionLocalProvider(*value){content()}

@Suppress("ComposableNaming")
@Composable
 fun Local.valueOf(context: CompositionLocalContext, content: @Composable () -> Unit) = androidx.compose.runtime.CompositionLocalProvider(context, content)


inline val Local.focusManager
    @Composable
    get() = LocalFocusManager.current

//它控制软键盘的显示和隐藏。
inline val Local.keyboardController: SoftwareKeyboardController?
    @Composable
    get() = LocalSoftwareKeyboardController.current

inline val Local.WindowInfo
    @Composable
    get() = LocalWindowInfo.current